package Demo9;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-21
 * Time: 15:02
 */
abstract class Animal{
    private String name;  //名字
    private int age;   //年龄
    public abstract void info();  //返回动物信息
    public abstract void speak(); //动物叫

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}

class Dog extends Animal{
    public int violence;

    public Dog(String name, int age, int violence) {
        super(name, age);
        this.violence=violence;
    }

    @Override
    public void info() {
        System.out.println("该狗的名字是"+getName()+",年龄是"+getAge()+"岁,凶猛程度是"+violence+"度");
    }

    @Override
    public void speak() {
        System.out.println("旺旺");
    }
}
class Cat extends Animal{
    public int mousingAbility;
    public Cat(String name, int age,int mousingAbility) {
        super(name, age);
        this.mousingAbility=mousingAbility;
    }

    @Override
    public void info() {
        System.out.println("该猫的名字是"+getName()+",年龄是"+getAge()+"岁,捕鼠能力是"+mousingAbility+"分");
    }

    @Override
    public void speak() {
        System.out.println("喵喵");
    }
}
class Factory{
    Animal getAnimalByType(int type,String name, int age, int ownAttribute){
        if (type == 1){
            return new Dog(name,age,ownAttribute);
        }
        else {
            return new Cat(name,age,ownAttribute);
        }
    }
}

public class Main {

    public static void main(String[] args) {
        Factory factory=new Factory();
        Scanner input=new Scanner(System.in);
        int type=input.nextInt();
        String name=input.next();
        int age=input.nextInt();
        int ownAttribute=input.nextInt();
        Animal a=factory.getAnimalByType(type, name, age, ownAttribute);
        a.info();
        a.speak();
        System.out.println(a.getName());
        System.out.println(a.getAge());
        input.close();
    }
}

/*请在这里填写你编写的Dog类、Cat类和Factory类 */